<div class="popup_body">
    <div class="ui_table">
        <form method="post">
            <input type="hidden" name="id" value="${(entity.id)!''}">
            <table cellpadding="0" cellspacing="0">
                <#if Session['SESSION_KEY_USER'].type == Session['USER_TYPE_PLATFORM'].value>
                    <tr>
                    <td align="right">运营商：</td>
                        <td>
                            <input name="agentId" class="easyui-combotree" editable="false"
                                   style="width: 184px; height: 28px;" id="agent_id" value="${(entity.agentId)!''}"
                                   data-options="url:'${contextPath}/security/basic/agent/tree.htm?',method:'get',onSelect: function(rec){
                                   var url = '${contextPath}/security/hdw/agency/tree.htm?agentId='+rec.id;
                                   $('#agency_id_${pid}').combotree('reload', url);},
                                   onChange:function(){
                                   $('#agency_id_${pid}').combotree('clear');
                                   }
                                   "/>
                        </td>
                    </tr>
                </#if>
                <#if Session['SESSION_KEY_USER'].type != Session['USER_TYPE_AGENCY'].value>
                    <tr>
                        <td width="80" align="right">代理商：</td>
                        <td>
                            <input name="agencyId" class="easyui-combotree" editable="false"
                                   style="width: 180px; height: 28px;" id="agency_id_${pid}"
                                   value="${(entity.agencyId)!''}"
                                   data-options="<#if Session['SESSION_KEY_USER'].agentId??&&Session['SESSION_KEY_USER'].agentId!=0>url:'${contextPath}/security/hdw/agency/tree.htm?agentId=${Session['SESSION_KEY_USER'].agentId}',</#if>method:'get'"
                            />
                        </td>
                    </tr>
                </#if>
                <tr>
                    <td width="80" align="right">套餐名称：</td>
                    <td><input type="text" class="text easyui-validatebox" required="required" maxlength="40"
                               name="priceName" value="${(entity.priceName)!''}" style="width: 168px; height: 28px;"/>
                    </td>
                </tr>
                <tr>
                    <td width="70" align="right">价格：</td>
                    <td><input id="price_${pid}" class="easyui-numberspinner" value="${((entity.price)/ 100 + "元")!''}"
                               style="width:180px;height: 30px " required="required"
                               data-options="min:0.01,precision:2">&nbsp;&nbsp;元
                    </td>
                </tr>
                <tr>
                    <td width="70" align="right">次数：</td>
                    <td><input type="text" maxlength="6" class="easyui-numberspinner" value="${(entity.number)!''}"
                               id="radio1"<#if entity.type==2> hidden</#if>
                               style="width: 180px; height: 28px;" name="number" required="required"
                               data-options="min:1,max:100"/></td>
                </tr>
                <tr>
                    <td width="70" align="right">天数：</td>
                    <td><input type="text" maxlength="6" class="easyui-numberspinner" value="${(entity.dayCount)!''}"
                               id="radio2" <#if entity.type==1> hidden</#if>
                               style="width: 180px; height: 28px;" name="dayCount" required="required"
                               data-options="min:1"/></td>
                </tr>
                <tr>
                    <td width="120" align="right">日使用上限：</td>
                    <td><input type="text" maxlength="6" class="easyui-numberspinner" value="${(entity.dayUse)!''}"
                               id="radio3" <#if entity.type==1> hidden</#if>
                               style="width: 180px; height: 28px;" name="dayUse" required="required"
                               data-options="min:1"/></td>
                </tr>
                <tr>
                    <td width="70" align="right">类型：</td>
                    <td>
                    <#if types??>
                        <#list types as type>
                            <input type="radio" class="radio"
                                   <#if type.getValue()==entity.type>checked </#if>name="type" required
                                   value="${type.getValue()}"/>${type.getName()}
                        </#list>
                    </#if>
                    </td>
                </tr>
                <tr>
                    <td align="right" valign="top" style="padding-top:10px;">备注：</td>
                    <td><textarea style="width:200px;" maxlength="120" name="memo">${(entity.memo)!''}</textarea></td>
                </tr>
            </table>
        </form>
    </div>
</div>
<div class="popup_btn">
    <button class="btn btn_red ok">确定</button>
    <button class="btn btn_border close">关闭</button>
</div>
<script>
    (function () {
        var pid = '${pid}',
                win = $('#' + pid),
                form = win.find('form');

        $(".radio").click(function () {
            if ($(this).val() == 1) {
                $("#radio1").show();
                $("#radio2").hide();
                $("#radio3").hide()
            } else {
                $("#radio1").hide();
                $("#radio2").show();
                $("#radio3").show()
            }
        });
        win.find('button.ok').click(function () {
            form.form('submit', {
                url: '${contextPath}/security/hdw/exchange_packet/update.htm',
                onSubmit: function (param) {
                    var price = $('#price_${pid}').numberspinner('getValue');
                    param.price = parseInt(Math.round(price * 100));
                    return true;
                },
                success: function (text) {
                    var json = $.evalJSON(text);
                <@app.json_jump/>
                    if (json.success) {
                        $.messager.alert('提示信息', '操作成功', 'info');
                        win.window('close');
                    } else {
                        $.messager.alert('提示信息', json.message, 'info');
                    }
                }
            });
        });

        win.find('button.close').click(function () {
            win.window('close');
        });
    })()
</script>
